package com.kmproject.haifu.mvp.ui.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jess.arms.utils.ArmsUtils;
import com.kmproject.haifu.R;
import com.kmproject.haifu.mvp.model.entity.beans.HousePayWayBean;

import java.util.List;

public class HousereportResponseAdapter extends BaseQuickAdapter<HousePayWayBean,BaseViewHolder> {
    private int selectInde=-1;
    private ClickItemCallback mclickItemCallback;
    public HousereportResponseAdapter(@Nullable List<HousePayWayBean> data,ClickItemCallback clickItemCallback) {
        super(R.layout.housereport_response_item, data);
        this.mclickItemCallback=clickItemCallback;
    }

    @Override
    protected void convert(BaseViewHolder helper, HousePayWayBean item) {
       helper.<TextView>getView(R.id.housereport_response_item_tv).setText(item.getName());
        helper.<TextView>getView(R.id.housereport_response_item_tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                selectInde=helper.getPosition();
                notifyDataSetChanged();mclickItemCallback.callBack(selectInde);

            }
        });
        if (selectInde==helper.getPosition())
        {
            helper.<TextView>getView(R.id.housereport_response_item_tv).setTextColor(ArmsUtils.getColor(mContext,R.color.color_191919));
            helper.<TextView>getView(R.id.housereport_response_item_tv).setBackgroundResource(R.drawable.square_yellow_bg);
        }else {
            helper.<TextView>getView(R.id.housereport_response_item_tv).setTextColor(ArmsUtils.getColor(mContext,R.color.white));
            helper.<TextView>getView(R.id.housereport_response_item_tv).setBackgroundResource(R.drawable.square_gray_bg);
        }
    }

    public int getSelectInde() {
        return selectInde;
    }

    public interface ClickItemCallback{
        void callBack(int index);
    }
}
